<?php


namespace App\Models;

class RoomModel extends Base
{

    protected $table = 'room';

    public $timestamps = false;

    protected $primaryKey = 'f_id';

    /**
     * Notes: 关联小区
     * User: lstink
     * Date: 2021/2/2
     * Time: 5:17 下午
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function community()
    {
        return $this->belongsTo(Community::class, 'c_id', 'community_id');
    }

    /**
     * Notes: 关联物业
     * User: lstink
     * Date: 2021/2/2
     * Time: 5:17 下午
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function estate()
    {
        return $this->belongsTo(Property::class, 'estate_id', 'id');
    }

    /**
     * Notes: 关联楼栋
     * User: lstink
     * Date: 2021/2/5
     * Time: 11:08 上午
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function house()
    {
        return $this->belongsTo(HouseModel::class, 'h_id', 'h_id');
    }

    /**
     * Notes: 关联单元
     * User: lstink
     * Date: 2021/2/5
     * Time: 9:38 上午
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function element()
    {
        return $this->belongsTo(ElementModel::class, 'e_id', 'e_id');
    }

    /**
     * Notes: 关联楼层
     * User: lstink
     * Date: 2021/3/4
     * Time: 4:18 下午
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function floor()
    {
        return $this->belongsTo(FloorModel::class, 'f_id', 'f_id');
    }

    /**
     * Notes: 关联用户
     * User: lstink
     * Date: 2021/3/4
     * Time: 4:18 下午
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'r_id', 'room_id');
    }

}
